require('./libs/jsOOP.js');
var Class = require('./libs/inherit.js');

//var JS = require('jsclass');

var JS = require('jsclass/src/set');
var s = new JS.Set([1, 2, 3]);


function Parent(value)
{
    this.parentMember1 = 111;
    this.setValue(value);
}

Parent.prototype.setValue = function (value)
{
    this.value = value;
    return this;
}

Parent.prototype.getValue = function ()
{
    return this.value;
}

Parent.prototype.toString = function ()
{
    return '(' + this.getValue() + ')';
}

var myParent = new Parent(0);
var myString = myParent.toString();

///-----
function Child(value)
{
    var aaa = this.super('toString');
    this.setValue(value);
    this.age = 3;
}

Child.inherits(Parent);

Child.prototype.toString = function ()
{
    if (this.getValue())
    {
        return this.super('toString');
    }
    return "-0-";
};

var myChild = new Child(10);
var myString = myChild.toString();


//-----------
var Person = Class.extend({
    init: function (isDancing, age)
    {
        this.dancing = isDancing;
        this.age = age;
    },

    dance: function ()
    {
        return this.dancing;
    }
});

var Ninja = Person.extend
    ({
        init: function (weaponName, age)
        {
            this._super(false, age);
            this.weaponName = weaponName;
        },

        dance: function ()
        {
            // Call the inherited version of dance()
            return this._super();
        },
        swingSword: function ()
        {
            return true;
        }
    });

var p = new Person(true, 22);
p.dance(); // => true
 
var n = new Ninja("dart", 33);
n.dance(); // => false
n.swingSword(); // => true

///--------------------

function FctorAsPrototype()
{
    this.fa = 11;
    this.fb = 22;
}

function ClsAsPrototype()
{
    this.a = 1;
    this.b = 2;

    //ClsAsPrototype.prototype.proto_a = 11;
}

ClsAsPrototype.prototype = FctorAsPrototype;
ClsAsPrototype.prototype = new FctorAsPrototype();

var obj6 = new ClsAsPrototype();
obj6.a;
obj6.fa;

var prototypeObj = new ClsAsPrototype();

var obj1 = {};
var obj2 = {};

obj1.__proto__ = prototypeObj;
obj2.__proto__ = prototypeObj;

obj1.a;
obj2.a;

prototypeObj.a = 3;

var obj3 = new ClsAsPrototype();
var obj4 = new ClsAsPrototype();

obj3.proto_a = 4;
obj4.proto_a;

ClsAsPrototype.prototype.proto_a = 55;

var obj5 = new ClsAsPrototype();
obj5.proto_a;
